#!ipxe

# Flatcar Container Linux
# https://flatcar-linux.org/
# For further info on:
# iPXE and flatcar Container Linux: https://www.flatcar.org/docs/latest/installing/bare-metal/booting-with-ipxe/
# Setting up Ignition: https://www.flatcar.org/docs/latest/installing/bare-metal/installing-to-disk/
# 64-bit only

goto ${menu}

:flatcar
set os {{ releases.flatcar.name }}
set os_arch ${arch}
iseq ${os_arch} x86_64 && set os_arch amd64 ||
iseq ${os_arch} arm64 && set os_arch arm64 ||
menu ${os} - Current Arch [ ${os_arch} ]
item --gap ${os}
{% for item in releases.flatcar.versions %}
item {{ item.code_name }} ${space} ${os} {{ item.name }}
{% endfor %}
item ignition_config ${space} Set ignition.config.url: ${ignition.config.url}
choose --default ${menu} menu || goto flatcar_exit
echo ${cls}
goto ${menu} ||
goto flatcar_exit

:stable
:beta
:alpha
:edge
set release ${menu}
set base-url https://${release}.release.flatcar-linux.net/${os_arch}-usr/current
kernel ${base-url}/flatcar_production_pxe.vmlinuz ${flatcar_firstboot} ${flatcar_params} flatcar.autologin=tty1 flatcar.autologin=ttyS0 initrd=flatcar_production_pxe_image.cpio.gz ${cmdline}
initrd ${base-url}/flatcar_production_pxe_image.cpio.gz
boot
goto flatcar_exit

:ignition_config
echo -n Please set Ignition URL: && read ignition.config.url
set flatcar_params ignition.config.url=${ignition.config.url}
set flatcar_firstboot flatcar.first_boot=1
clear menu
goto flatcar

:flatcar_exit
clear menu
exit 0
